<template>
  <div class="dizhi">
    <header> <span class="iconfont icon-zuojiantou1" @click="fanhui"></span><p>新增</p></header>
<van-address-list
  v-model="chosenAddressId"
  :list="$store.state.dizhilist"
  :disabled-list="disabledList"
  disabled-text="以下地址超出配送范围"
  @add="onAdd"
  @edit="onEdit"
>
</van-address-list>
  </div>
</template>

<script>
import { Toast } from 'vant';
import {areaList} from "@vant/area-data"
export default {
  data() {
    return {
      areaList,
      searchResult: [],
      chosenAddressId: '1',
      list: [],
      oldlist:[],
      disabledList: [
        {
          id: '3',
          name: '王五',
          tel: '1320000000',
          address: '浙江省杭州市滨江区江南大道 15 号',
        },
      ],
    };
  },
  methods: {
    onSave() {
      Toast('已保存');
    },
    onDelete() {
      Toast('删除');
    },
    onAdd(){
     this.$router.push("/dizhi")
  
    },
  
      onEdit(item, index) {
              console.log('W cak')
              console.log(this.list[index].id)
            
             this.$router.push("/dizhibj/"+this.list[index].id)
        },
       lista(){
              let userid=localStorage.getItem("userid")
              this.$store.dispatch('bddTask',userid)
              // this.$store.dispatch('addTask',userid)
          
        },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: '黄龙万科中心',
            address: '杭州市西湖区',
          },
        ];
      } else {
        this.searchResult = [];
      }
    },
     
       fanhui(){
            this.$router.go(-1)
       }
  },
  mounted(){
     this. lista()
     this.list=this.$store.state.dizhilist
  }
};
</script>

<style scoped>
.dizhi{
  padding: 10px;
}
header{
  margin-top:20px ;
  padding-left:30px ;
  display: flex;
}
header span{
  margin: 20px;
}

</style>
